package com.kfm.base.oop2;

public class GirlFriend {

    /*
        只能在同包访问
     */
    public String name;

    protected double height;

    double weight;

    // 0 女 1 男
    private byte gender;

    private int age;

    public GirlFriend() {
        /*
        使用this调用其他的构造方法
            this([实参列表]) 调用重载的构造, 只能在构造的第一个语句
         */
        this.name = "花花";
//        this("佚名", 160, 50);
//        System.out.println("GirlFriend()");
    }

    public GirlFriend(String name, double height, double weight) {
        /*
           this 我(当前对象), 谁执行(调用)就是谁
            this调用实例变量、调用实例方法、静态成员（不推荐）
            只能在实例成员中、实例初始化、构造方法
         */
        this.name = name;
        this.weight = weight;
        this.height = height;
//        this.age = 18;
        setAge(18);
    }

    // getter、setter
    public void setAge(int age) {
        if (age <= 16 || age >= 100) {
            this.age = 18; // 报错
        } else {
            this.age = age;
        }
    }

    public int getAge() {
        return age;
    }

    public void setGender(char gender) {
        if ('男' == gender) {
            this.gender = 1;
        } else {
            this.gender = 0;
        }
    }

    public char getGender() {
        return this.gender == 1 ? '男' : '女';
    }

    public void setName(String name) {
        this.name = name;
    }

    public void wash() {
        System.out.println("女朋友帮我洗衣服");
    }

    public void cook() {
        System.out.println("女朋友给我做饭");
    }

    public String show() {
        return "女朋友是 " + name + ", 年龄是 " + age + "岁， 身高是 " + height + " 厘米, 体重是 " + weight + " 公斤";
    }
}
